<?php
namespace app\web\controller;

use app\model\Theme; 
use app\model\Poster; 

class ThemeSoftsn extends Base
{
    public function Theme_softsn()
    {
global $_G, $_P;
$system = $_G['system'];
$_G['page']['title'] = '激活确认 - ' . $system['sysname'];
$themeid = intval($_P['themeid']);
if (empty($themeid)) {
    return_msg('参数错误');
}
if (!$_G['isSuperAdmin']){
    return_msg('无权查看');
}
$max_score = 50;
$config = Theme::getConfig($themeid);
$theme = Theme::getThemeById($themeid);
$do = 'theme_softsn';
$op = !empty($_P['op']) ? $_P['op'] : 'display';
$softsn_tips = ['已审核','专版待确认','专版借用待审核','专版误报待审核','专版借用未通过','专版误报审核未通过'];
if ($op == 'display'){
    $softsndata = array(
        'software'    => MODULE_NAME,
        'uniacid'  => $_G['mpid'],
        'themeid' => $themeid,
        'softsn' => $theme ['softsn'],
        'headimg' => $theme ['headimg'],
        'title' => $theme ['title'],
    );
    $result = Poster::Getbanklist($system,'getExclusiveList',$softsndata);
    $city_list = $result['city_list'];
    $exclusive = $result['exclusive'];
    $status =0;
    if (!empty($exclusive['imgs'])){
        $zhuanbangs = $exclusive['imgs'][0]['xiuchanggs'];
        if (!empty($theme['laoshi'])){
            $themegs = explode('-',$theme['laoshi'])[0];
        }
        if ($zhuanbangs == $themegs){
            $status = 4;
        }
    }
//    var_dump($result);
    $return_clicent = get_defined_vars();
return view('/theme_softsn' , $return_clicent);
}elseif($op == 'confirm'){
    $type = intval($_P['status']);
    $status = $type;
    if ($type==4){$status=0;}
    db_update (t_theme,array('softsn_status'=>$status), array('id'=>$themeid));
    $url = createWebUrl('theme');
    $softsn_tips2 = ['无冲突专版，确认同地区也无冲突','','专版借用审核','专版误报审核','专版秀场公司自用'];
    yxlog($softsn_tips2[$type],'专版');

    $softsndata = array(
        'software'    => MODULE_NAME,
        'uniacid'  => $_G['mpid'],
        'themeid' => $themeid,
        'softsn' => $theme ['softsn'],
        'headimg' => $theme ['headimg'],
        'title' => $theme ['title'],
        'type' => $type,
        'remark' => date('Y-m-d H:i:s',time()) . " ：". $_G['username'] .' '.$softsn_tips2[$type],
    );
    $result = Poster::Getbanklist($system,'saveExclusiveList',$softsndata);

    return_tips ( $softsn_tips2[$type], $url, 'success' );
}
}
}